USE [AdventureWorksLT2012]
GO

/****** Object:  StoredProcedure [dbo].[CustomersGet]    Script Date: 6/11/2014 4:39:16 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[CustomersGet]
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure 
	SELECT        SalesLT.Customer.CustomerID, SalesLT.Customer.Title, SalesLT.Customer.FirstName, SalesLT.Customer.LastName, SalesLT.Customer.CompanyName, SalesLT.Customer.SalesPerson, 
                         SalesLT.Customer.EmailAddress, SalesLT.Customer.Phone, SalesLT.Address.AddressLine1, SalesLT.Address.AddressLine2, SalesLT.Address.City, 
                         SalesLT.Address.StateProvince, SalesLT.Address.CountryRegion, SalesLT.Address.PostalCode
FROM            SalesLT.Address INNER JOIN
                         SalesLT.CustomerAddress ON SalesLT.Address.AddressID = SalesLT.CustomerAddress.AddressID INNER JOIN
                         SalesLT.Customer ON SalesLT.CustomerAddress.CustomerID = SalesLT.Customer.CustomerID
WHERE        (SalesLT.Address.CountryRegion = N'United States')
ORDER BY LastName, FirstName
END

GO

